#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
    int n, i, x, max, min;
    cin >> n;
    cin >> x;
    max = x;
    min = x;
    for (int i = 2; i <= n; ++i) {
        cin >> x;
        if (x > max)
            max = x;
        if (x < min)
            min = x;
    }
    printf("%d", max - min);
    return 0;
}
